package net.bbtang.website.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.bbtang.website.mapper.UserPublishInfoMapper;
import net.bbtang.website.pojo.UserPublishInfoDTO;
import net.bbtang.website.service.UserPublishInfoService;

@Service("userPublishInfoServiceImpl")
public class UserPublishInfoServiceImpl implements UserPublishInfoService {
	
	@Autowired
	private UserPublishInfoMapper userPublishInfoMapper;
	
	@Override
	public boolean add(UserPublishInfoDTO dto) {
		userPublishInfoMapper.add(dto);
		return true;
	}

	@Override
	public boolean cancel(UserPublishInfoDTO dto) {
		dto.setPublishState(3);
		userPublishInfoMapper.updateStatue(dto);
		return true;
	}

	@Override
	public List<UserPublishInfoDTO> search(Integer currentSize, Integer userId, Integer publishId, Integer publishType,
			Integer publishState, Integer userGroupId) {
		if (currentSize == null){
			currentSize = 0;
		}
		
		return userPublishInfoMapper.search(currentSize, userId,publishId, publishType,publishState,userGroupId);
	}
	
	@Override
	public List<UserPublishInfoDTO> searchAll( Integer userId, Integer publishId, Integer publishType,
			Integer publishState, Integer userGroupId) {
		return userPublishInfoMapper.searchAll( userId,publishId, publishType,publishState,userGroupId);
	}

}
